add password change page
authorFelix Fietkau <[email protected]>
Sun, 5 Feb 2006 05:24:51 +0000 (05:24 +0000)
committerFelix Fietkau <[email protected]>
Sun, 5 Feb 2006 05:24:51 +0000 (05:24 +0000)
SVN-Revision: 3137

openwrt/package/webif/files/usr/lib/webif/validate.awk
openwrt/package/webif/files/www/cgi-bin/webif/password.sh [new file with mode: 0755]

index 490b128160a0be5535b4c2afd001be0ac52ccdec..dfbe12028750150529b09c442818aab6d7954da4 100644 (file)
@@ -98,9 +98,9 @@ valid == 1 {
                        sub(/^min=/, "", min)
                        min = int(min)
                        if ($1 == "int") {
-                               if (value < min) { valid = 0; verr = "Value too small" }
+                               if (value < min) { valid = 0; verr = "Value too small (minimum: " min ")" }
                        } else if ($1 == "string") {
-                               if (length(value) < min) { valid = 0; verr = "Value too small: "  length(value) " < " min }
+                               if (length(value) < min) { valid = 0; verr = "Value too small (minimum length: " min ")"}
                        }
                } else if ((options[i] ~ /^max=/) && (value != ""))  {
                        max = options[i]
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/password.sh b/openwrt/package/webif/files/www/cgi-bin/webif/password.sh
new file mode 100755 (executable)
index 0000000..d0b66eb
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/haserl
+<? 
+. /usr/lib/webif/webif.sh
+
+empty "$FORM_submit" || {
+       SAVED=1
+       validate <<EOF
+string|FORM_pw1|Password|required min=5|$FORM_pw1
+EOF
+       equal "$FORM_pw1" "$FORM_pw2" || {
+               ERROR="$ERROR Passwords do not match<br />"
+       }
+       empty "$ERROR" && {
+               RES=$(
+                       (
+                               echo "$FORM_pw1"
+                               sleep 1
+                               echo "$FORM_pw2"
+                       ) | passwd root
+               )
+               equal "$?" 0 || ERROR="<pre>$RES</pre>"
+       }
+}
+
+header "System" "Password" "Password change" '' "$SCRIPT_NAME"
+
+display_form <<EOF
+start_form|System settings
+field|New Password:
+password|pw1
+field|Confirm Password:
+password|pw2
+end_form
+EOF
+
+footer ?>
+
+<!--
+##WEBIF:name:System:0:Password
+-->